package com.shop.codegen;

import com.jfinal.kit.Kv;
import com.jfinal.kit.PathKit;
import com.jfinal.template.Engine;
import com.jfinal.template.Template;

/**
 * creat_user:  denghuanqing
 * creat_date: 2018/1/5
 * creat_time: 17:45
 * describe:测试jfinal模板引擎api
 **/
public class TestEngine {
    public static void main(String[] args) {
        /**
         * 1.填充map参数
         * 2.在模板文件中替换参数值
         * 3.生成String返回
         */
        Engine engine = Engine.create("forTest");
        engine.setBaseTemplatePath(PathKit.getWebRootPath()+"/src/main/resources/codeTemplate");

        Template template = Engine.use("forTest").getTemplate("test01.html");
        Kv by = Kv.by("baseModelPackageName", "java");

        String s = template.renderToString(by);
        System.out.println("--------------------------");
        System.out.println(s);
        System.out.println("--------------------------");
    }
}
